<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"    xmlns:f="http://java.sun.com/jsf/core"        
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:c="http://java.sun.com/jsp/jstl/core">
 <ui:composition template="../../templates/admin/template.xhtml"> 
        <ui:define name="content">
        
            <h:form styleClass="jsfcrud_list_form">
                <div style="search">                    
                    <h:inputText id ="search" value="#{adminUsersBean.search}"
                                 required="true"
                                 requiredMessage="Search term required"
                                 validatorMessage="Invalid name">
                        <f:validateRegex pattern="#{validation.name}"/>
                     </h:inputText>
                    <div>
                        <h:message for="search" styleClass="errorMessage"/>
                    </div> 
                    <h:commandButton action="#{adminUsersBean.searchUsers}" value="Search Name"/>
                </div>
            
                <h:dataTable value="#{adminUsersBean.users}" var="u" border="0" cellpadding="2" cellspacing="0"  style="border:solid 1px">
                    <h:column>
                       <f:facet name="header">
                       <h:outputText value="Name"/>
                       </f:facet>
                       <h:outputText value="#{u.name}"/>
                    </h:column>
                    <h:column>
                       <f:facet name="header">
                       <h:outputText value="Last name"/>
                       </f:facet>
                        <h:outputText value="#{u.lastName}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                        <h:outputText value="Email"/>
                        </f:facet>
                        <h:outputText value="#{u.email}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                        <h:outputText value="Password"/>
                        </f:facet>
                        <h:outputText value="#{u.password}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                        <h:outputText value="Registration date"/>
                        </f:facet>
                        <h:outputText value="#{u.registrationDate}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                        <h:outputText value="Active"/>
                        </f:facet>
                        <h:outputText value="#{u.active}"/>
                    </h:column>

                    <h:column>
                            <f:facet name="header">
                            <h:outputText value="Options"/>
                            </f:facet>
                        <h:commandLink action="#{adminUsersBean.deleteUser(u)}" value="#{msgs.delete}"/>|
                        <h:commandLink action="#{adminUsersBean.viewUser(u)}" value="#{msgs.view}"/>
                    </h:column>
             </h:dataTable>
            <div>
                
                |<h:commandLink action="#{adminUsersBean.previous()}" 
                               value="#{msgs.previous}"/>|
                <h:commandLink action="#{adminUsersBean.next()}" 
                               value="#{msgs.next}"/>|
            </div>    
            </h:form>
            

        </ui:define>
</ui:composition>

</html>